import os
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

class Config:
    SECRET_KEY = os.environ.get('SECRET_KEY', 'change-me')
    # SQLite（默认）；改 MySQL：mysql+pymysql://user:pwd@host:3306/jade

    SQLALCHEMY_DATABASE_URI = os.environ.get(
        'DATABASE_URL',
        'mysql+pymysql://root:zacklam11@127.0.0.1:3306/uow?charset=utf8mb4'
    )
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 连接池更稳一点
    SQLALCHEMY_ENGINE_OPTIONS = {
        "pool_pre_ping": True,
        "pool_recycle": 1800,
        "pool_size": 5,
        "max_overflow": 10,
    }
    UPLOAD_FOLDER = str(BASE_DIR / 'uploads')

    MAX_CONTENT_LENGTH = 10 * 1024 * 1024 # 10MB

    CONTACT_EMAIL = os.environ.get('CONTACT_EMAIL', 'zackincrazy@gmail.com')
    WHATS_NUMBER = os.environ.get('WHATS_NUMBER', '')
    WECHAT_KF_URL = os.environ.get('WECHAT_KF_URL', '')
    WECHAT_QR_PATH = os.environ.get('WECHAT_QR_PATH', 'images/wechat_qr.png')
    PAYPAL_ENV = os.environ.get('PAYPAL_ENV', 'live')
    PAYPAL_CLIENT_ID = os.environ.get('PAYPAL_CLIENT_ID', '')
    PAYPAL_SECRET = os.environ.get('PAYPAL_SECRET, ''')
    # i18n
    BABEL_TRANSLATION_DIRECTORIES = str(BASE_DIR / 'translations')
    BABEL_DEFAULT_LOCALE = os.environ.get('BABEL_DEFAULT_LOCALE', 'en')
    BABEL_DEFAULT_TIMEZONE = os.environ.get('BABEL_DEFAULT_TIMEZONE', 'Asia/Singapore')

    LANGUAGES = ['zh', 'en']